import {API} from '../api/index.js'

/**
 * 获取用户地址列表
 */
const _ajaxaddressList = function(uid) {
    const url = "/mobile/user/ajaxaddressList";
    const result = API.post(url,{user_id:uid});
    return result;
};

/**
 * 添加/编辑地址
 * @param {*} param 
 */
const _ajaxaddress=function(param){
    const url="/mobile/user/ajaxaddress";
    const result=API.post(url,param);
    return result
}



/**
 * 删除地址
 * @param {*} param 
 */
const _deleteAddress=function(param){
    let uid=JSON.parse(localStorage.getItem('user')).user_id 
    const url="/mobile/user/deleteAddress";
    const result=API.post(url,{address_id:param,user_id:uid});
    return result
}


/**
 * 设为默认地址
 * @param {*} param 
 */
const _is_top=function(id,uid){
    const url="/mobile/user/is_top";
    const result=API.post(url,{address_id:id,is_top:1,user_id:uid});
    return result
}


/**
 * 获取地址详情
 * @param {*} param 
 */
const _getAddressInfo=function(param){
    const url="/mobile/user/getAddressInfo";
    const result=API.post(url,param);
    return result
}

export {
    _ajaxaddressList,
    _ajaxaddress,
    _deleteAddress,
    _is_top,
    _getAddressInfo
}